package com.king.diy;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

//方式三使用注解方式实现aop
@Aspect//标记为一个切面
public class AnnotationPointcut {

    @Before("execution(* com.king.service.UserServiceImp.*(..))")
    public void before(){
        System.out.println("方法执行前====");
    }

    @After("execution(* com.king.service.UserServiceImp.*(..))")
    public void After(){
        System.out.println("方法执行后===");
    }


    @Around("execution(* com.king.service.UserServiceImp.*(..))")
    public void Around(ProceedingJoinPoint jp) throws Throwable {
        System.out.println("方法执行环绕=====");
        System.out.println(jp.getSignature());
        Object proceed = jp.proceed();
        System.out.println(proceed);
        System.out.println("环绕后======");
    }

}
